<?php

/**
 *      This is NOT a freeware, use is subject to license terms
 *      应用名称: 企业公司模板官网 X3.5版本
 *      下载地址: https://addon.dismall.com/templates/wpui_mb2.html
 *      应用开发者: WPUI
 *      开发者QQ: 811381171
 *      更新日期: 202409101510
 *      授权域名: www.zkdjc.com
 *      授权码: 2024091014w5qn5ncxpX
 *      未经应用程序开发者/所有者的书面许可，不得进行反向工程、反向汇编、反向编译等，不得擅自复制、修改、链接、转载、汇编、发表、出版、发展与之有关的衍生产品、作品等
 */

/**
* 用吖(重庆)科技有限公司 WPUI出品
* Q Q: 517664276
*/
if(!defined('IN_DISCUZ')) {exit('Access Denied');}

function artical_attchs($aid){
	$artical_attchs = DB::result(DB::query("SELECT attachment FROM ".DB::table('portal_attachment')." WHERE aid = '$aid'"));
	return $artical_attchs;
}
function test(){
	global $_G;
	//print_r($_G);
}
function testData(){
	global $_G;
	$data = DB::fetch_all("select * from ".DB::table('portal_article_title'));
	//print_r($data);
}
function testDataInfo(){
	//$rs = DB::fetch_first('select * from '.DB::table('nciaer_demo').' where id = 1');
}

function wpui_plugin(){
	$rs = DB::fetch_first('select * from '.DB::table('wpui_mb1_config').' where id = 1');
	return $rs;
}

/**
* 底部导航
*/
function footernavs(){
	global $_G;
	$footernavs = $_G['setting']['footernavs'];
	$left=array();
	$right=array();
	$js=0;
	foreach($footernavs as $k=>$v){
		if($js<=3 && $v['available']==1){
			$js++;
			$temp['url']="<dd>".$v['code']."</dd>";
			$left[]=$temp;
		}else if($js>=4 &&$js<=7 && $v['available']==1){
			$js++;
			$temp['url']="<dd>".$v['code']."</dd>";
			$right[]=$temp;
		}
		
	}
	//print_r(array("left"=>$left,"right"=>$right));
	return array("left"=>$left,"right"=>$right);
}


/**
* 首页banner
*/
function banner(){
	global $_G;
	$data=array();
	$row = DB::fetch_first('select * from '.DB::table('wpui_mb1_config').' where id = 1');
	if($row['banner1']){
		$data[]=$row['banner1'];
	}
	if($row['banner2']){
		$data[]=$row['banner2'];
	}
	if($row['banner3']){
		$data[]=$row['banner3'];
	}
	if($row['banner4']){
		$data[]=$row['banner4'];
	}
	return $data;
}
/**
* 最新的文章
*/
function news(){
	global $_G;
	$catid = intval($_G['catid']);
	$cat = DB::fetch_first('select * from '.DB::table('portal_category').' where catid ='.$catid);
	if($cat['upid']==0){
		$id=$cat['catid'];
		$sub = DB::fetch_all("select * from ".DB::table('portal_category')." where upid=".$catid);
		foreach($sub as $v){
			$id .= ','.$v['catid'];
		}
	}else{
		$id = $cat['upid'];
		$sub = DB::fetch_all("select * from ".DB::table('portal_category')." where upid=".$cat['upid']);
		foreach($sub as $v){
			$id .= ','.$v['catid'];
		}
	}
	$data = DB::fetch_all("select aid,title,pic,catid,summary,dateline from ".DB::table('portal_article_title')." where catid in($id) order by aid desc limit 0,5");
	foreach($data as $k=>$v){
		$data[$k]['pic']=$_G['setting']['attachurl'].$v['pic'];
		$data[$k]['dateline']=date("Y-m-d H:i",$v['dateline']);
		$data[$k]['url']=fetch_article_url($v);
	}
	return $data;
}

/**
* 推荐的文章
*/
function recommend(){
	global $_G;
	$catid = intval($_G['catid']);
	$cat = DB::fetch_first('select * from '.DB::table('portal_category').' where catid ='.$catid);
	if($cat['upid']==0){
		$id=$cat['catid'];
		$sub = DB::fetch_all("select * from ".DB::table('portal_category')." where upid=".$catid);
		foreach($sub as $v){
			$id .= ','.$v['catid'];
		}
	}else{
		$id = $cat['upid'];
		$sub = DB::fetch_all("select * from ".DB::table('portal_category')." where upid=".$cat['upid']);
		foreach($sub as $v){
			$id .= ','.$v['catid'];
		}
	}
	$data = DB::fetch_all("select aid,title,pic,catid,summary,dateline from ".DB::table('portal_article_title')." where catid in($id) and tag>127 order by aid desc limit 0,4");
	foreach($data as $k=>$v){
		$data[$k]['pic']=$_G['setting']['attachurl'].$v['pic'];
		$data[$k]['dateline']=date("Y-m-d H:i",$v['dateline']);
		$data[$k]['url']=fetch_article_url($v);
	}
	return $data;
}
    		  	  		  	  		     	  	 			    		   		     		       	   	 		    		   		     		       	   	 		    		   		     		       	   				    		   		     		       	   	 	    		   		     		       	 	        		   		     		       	 	        		   		     		       	   	       		   		     		       	   	       		   		     		       	   	       		   		     		       	 	   	    		   		     		       	    	 	    		   		     		       	  	 	      		   		     		       	  		 		    		   		     		       	  	 	 	    		   		     		       	  			      		   		     		       	 	   	    		   		     		       	  			      		   		     		       	  	        		   		     		       	  	  	     		   		     		       	 	        		 	      	  		  	  		     	
?>